home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1993 July / Nautilus CD Magazine Volume 3-7 July 1993 Windows Edition.mdf / educ / win32s / 32sinst.mst < prev    next >
Text File  |  1993-03-07  |  9KB  |  339 lines

  1. '**************************************************************************
  2. '*                       MSSetup Toolkit Sample 1
  3. '**************************************************************************
  4.  
  5. '' $DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST WELCOME       = 100
  12. CONST ASKQUIT       = 200
  13. CONST DESTPATH      = 300
  14. CONST EXITFAILURE   = 400
  15. CONST EXITQUIT      = 600
  16. CONST EXITSUCCESS   = 700
  17. CONST OPTIONS       = 800
  18. CONST BADPATH       = 6400
  19.  
  20. CONST HELPWELCOME   = 1000
  21. CONST VERPATH       = 1100
  22. CONST EXITFAILNOTWIN31 = 1200
  23. CONST EXITFAILNOTENH = 1300
  24. CONST EXITFAILNOTINTEL = 1350
  25. CONST FREECELLINST  = 1400
  26. CONST FREECELLINSTNOWIN32S = 1450
  27. CONST FREECELLPATH  = 1500
  28. CONST HELPFREECELL  = 1600
  29.  
  30.  
  31. ''Bitmap ID
  32. CONST LOGO = 1
  33.  
  34. GLOBAL DESTSYS$      ''Windows\System directory.
  35. GLOBAL DEST32S$      ''Windows\System\Win32s directory
  36. GLOBAL DESTFREE$     ''Freecell directory
  37.  
  38. DECLARE SUB Install
  39. DECLARE SUB UpdateSystemIni
  40. DECLARE SUB RebootSystem
  41. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  42. DECLARE FUNCTION MakeSystemIni LIB "INIUPD.DLL" (arg1$, arg2$) AS INTEGER
  43. DECLARE FUNCTION RestartWindows LIB "INIUPD.DLL" (arg1$) AS INTEGER
  44. DECLARE FUNCTION OnWindowsNT LIB "INIUPD.DLL" AS INTEGER
  45.  
  46. INIT:
  47.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  48.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  49.  
  50.     SetBitmap CUIDLL$, LOGO
  51.     SetTitle "Microsoft Win32s Setup Program"
  52.  
  53.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  54.     IF szInf$ = "" THEN
  55.     szInf$ = GetSymbolValue("STF_CWDDIR") + "32sinst.inf"
  56.     END IF
  57.     ReadInfFile szInf$
  58.  
  59.     DESTSYS$ = GetWindowsSysDir()
  60.     DEST32S$ = DESTSYS + "WIN32S\"
  61.  
  62. '$IFDEF DEBUG
  63.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  64.     WinDrive$ = MID$(GetWindowsDir, 1, 1)
  65.     IF IsDriveValid(WinDrive$) = 0 THEN
  66.     i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  67.     GOTO QUIT
  68.     END IF
  69. '$ENDIF ''DEBUG
  70.  
  71. CHECK:
  72.     WIN32ENABLED% = 0
  73.     IF GetWindowsMajorVersion < 3 THEN
  74.     ExitCode% = EXITFAILNOTWIN31
  75.     GOTO QUIT
  76.     END IF
  77.     IF GetWindowsMajorVersion = 3 AND GetWindowsMinorVersion < 1 THEN
  78.     ExitCode% = EXITFAILNOTWIN31
  79.     GOTO QUIT
  80.     END IF
  81.     IF GetWindowsMajorVersion >= 4 THEN
  82.     ExitCode% = EXITSUCCESS
  83.     WIN32ENABLED% = 1
  84.     GOTO FREECELL
  85.     END IF
  86.     IF GetWindowsMode < 2  THEN
  87.     IF OnWindowsNT() THEN
  88.        ExitCode% = EXITFAILNOTINTEL    '' Running on Windows NT (on RISC)
  89.     ELSE
  90.        ExitCode% = EXITFAILNOTENH    '' Standard Mode Windows
  91.     END IF
  92.     GOTO QUIT
  93.     END IF
  94.     IF OnWindowsNT() THEN
  95.     ExitCode% = EXITSUCCESS
  96.     WIN32ENABLED% = 1
  97.     GOTO FREECELL
  98.     END IF
  99.     ExitCode% = EXITSUCCESS
  100.  
  101.     szOldVer$ = GetVersionOfFile( DESTSYS$ + "WIN32S16.DLL" )
  102.     szNewVer$ = GetVersionOfFile( GetSymbolValue("STF_SRCDIR") + "WIN32S16.DLL" )
  103.  
  104.     IF "1" <> GetIniKeyString( DESTSYS$ + "WIN32S.INI", "Win32s", "Setup") THEN
  105.     GOTO WELCOME
  106.     END  IF
  107.  
  108.     IF szOldVer$ = "" THEN
  109.     GOTO WELCOME
  110.     END IF
  111.     IF szNewVer$ > szOldVer$ THEN
  112.     GOTO WELCOME
  113.     END IF
  114.     WIN32ENABLED% = 1
  115.     GOTO FREECELL
  116.  
  117. WELCOME:
  118.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", HELPWELCOME, HELPPROC$)
  119.     IF sz$ = "CONTINUE" THEN
  120.     UIPop 1
  121.     ELSE
  122.     GOSUB ASKQUIT
  123.     GOTO WELCOME
  124.     END IF
  125.  
  126.  
  127. GETWIN32SPATH:
  128.     SetSymbolValue "EditTextIn", DESTSYS$
  129.     SetSymbolValue "EditFocus", "END"
  130.  
  131. GETPATHL1:
  132.     sz$ = UIStartDlg(CUIDLL$, VERPATH, "FDispDlgProc", HELPWELCOME, HELPPROC$)
  133.  
  134.     IF sz$ = "CONTINUE" THEN
  135.     IF IsDirWritable(DESTSYS$) = 0 THEN
  136.         GOSUB BADPATH
  137.         GOTO GETPATHL1
  138.     END IF
  139.     UIPop 1
  140.     ELSEIF sz$ = "REACTIVATE" THEN
  141.     GOTO GETPATHL1
  142.     ELSEIF sz$ = "BACK" THEN
  143.     UIPop 1
  144.     GOTO WELCOME
  145.     ELSE
  146.     GOSUB ASKQUIT
  147.     GOTO GETPATHL1
  148.     END IF
  149.  
  150. COPYFILES:
  151.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  152.  
  153.     CreateDir DEST32S$, cmoNone
  154.     Install
  155.     UpdateSystemIni
  156.  
  157.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "1", cmoOverwrite
  158.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Version", szNewVer$, cmoOverwrite
  159.  
  160.  
  161. FREECELL:
  162.     IF WIN32ENABLED% = 1 THEN
  163.     sz$ = UIStartDlg(CUIDLL$, FREECELLINSTNOWIN32S, "FInfoDlgProc",0, "")
  164.     ELSE
  165.     sz$ = UIStartDlg(CUIDLL$, FREECELLINST, "FInfoDlgProc",0, "")
  166.     END IF
  167.     IF sz$ = "CONTINUE" THEN
  168.     UIPop 1
  169.     ELSE
  170.     GOTO QUIT
  171.     END IF
  172.  
  173. GETFREEPATH:
  174.     DESTFREE$ = MID$(DESTSYS$,1,3) + "WIN32APP\FREECELL\"
  175.     SetSymbolValue "EditTextIn", DESTFREE$
  176.     SetSymbolValue "EditFocus", "END"
  177.  
  178. GETFREEPATHL1:
  179.     sz$ = UIStartDlg(CUIDLL$, FREECELLPATH, "FEditDlgProc", HELPFREECELL, HELPPROC$)
  180.  
  181.     IF sz$ = "CONTINUE" THEN
  182.     DESTFREE$ = GetSymbolValue("EditTextOut")
  183.  
  184.     IF MID$(DESTFREE$, LEN(DESTFREE$), 1) <> "\" THEN
  185.         DESTFREE$ = DESTFREE$ + "\"
  186.     END IF
  187.     ''Validate new path.
  188.     IF IsDirWritable(DESTFREE$) = 0 THEN
  189.         GOSUB BADPATH
  190.         GOTO GETFREEPATHL1
  191.     END IF
  192.     UIPop 1
  193.  
  194.     GOTO COPYFREECELL
  195.     ELSEIF sz$ = "REACTIVATE" THEN
  196.     GOTO GETFREEPATHL1
  197.     ELSEIF sz$ = "EXIT" THEN
  198.     UIPop 1
  199.     GOTO QUIT
  200.     END IF
  201.  
  202. COPYFREECELL:
  203.     ClearCopyList
  204.     CreateDir DESTFREE$, cmoNone
  205.  
  206.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  207.  
  208.     AddSectionFilesToCopyList "Win32appFreecell", SrcDir$, DESTFREE$
  209.     CopyFilesInCopyList
  210.  
  211.     CreateProgmanGroup "Win32 Applications", "", cmoNone
  212.     ShowProgmanGroup   "Win32 Applications", 1, cmoNone
  213.     CreateProgmanItem  "Win32 Applications", "Freecell", DESTFREE$ + "FREECELL.EXE", "", cmoOverwrite
  214.  
  215.     IF DoesFileExist( DESTSYS$ + "WIN32S.INI", femExists ) THEN
  216.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Freecell", "Setup", "1", cmoOverwrite
  217.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Freecell", "Version", szNewVer$, cmoOverwrite
  218.     END IF
  219.  
  220.     i% = DoMsgBox("Freecell was successfully installed.", "Freecell Setup", MB_OK+MB_TASKMODAL)
  221.  
  222.  
  223. QUIT:
  224.     ON ERROR GOTO ERRQUIT
  225.     IF ERR = 0 THEN
  226.     dlg% = ExitCode%
  227.     ELSEIF ERR = STFQUIT THEN
  228.     dlg% = EXITQUIT
  229.     ELSE
  230.     dlg% = EXITFAILURE
  231.     END IF
  232.  
  233. QUITL1:
  234.     IF WIN32ENABLED% = 1 THEN
  235.     UIPop 1
  236.     END
  237.     END IF
  238.  
  239.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  240.     IF sz$ = "REACTIVATE" THEN
  241.     GOTO QUITL1
  242.     END IF
  243.     UIPop 1
  244.  
  245.     RebootSystem
  246.  
  247.     END
  248.  
  249. ERRQUIT:
  250.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  251.     END
  252.  
  253.  
  254.  
  255. BADPATH:
  256.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  257.     IF sz$ = "REACTIVATE" THEN
  258.     GOTO BADPATH
  259.     END IF
  260.     UIPop 1
  261.     RETURN
  262.  
  263.  
  264.  
  265.   ASKQUIT:
  266.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  267.  
  268.     IF sz$ = "EXIT" THEN
  269.     UIPopAll
  270.     ERROR STFQUIT
  271.     ELSEIF sz$ = "REACTIVATE" THEN
  272.     GOTO ASKQUIT
  273.     ELSE
  274.     UIPop 1
  275.     END IF
  276.     RETURN
  277.  
  278.  
  279.  
  280. '**
  281. '** Purpose:
  282. '**     Builds the copy list and performs all installation operations.
  283. '** Arguments:
  284. '**     none.
  285. '** Returns:
  286. '**     none.
  287. '*************************************************************************
  288. SUB Install STATIC
  289.  
  290.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  291.  
  292.     AddSectionFilesToCopyList "WindowsSystem", SrcDir$, DESTSYS$
  293.     AddSectionFilesToCopyList "WindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\"
  294.  
  295.     t% = RestartWindows( GetWindowsSysDir() + "OLECLI.DLL" )
  296.     SetRestartDir GetWindowsDir()
  297.     CopyFilesInCopyList
  298.  
  299. END SUB
  300.  
  301. SUB UpdateSystemIni STATIC
  302.  
  303.     VxDPath$ = DEST32S$ + "W32S.386"
  304.     SystemIniPath$ = GetWindowsDir()
  305.  
  306.     t% = MakeSystemIni(SystemIniPath$, VxdPath$)
  307.  
  308. END SUB
  309.  
  310. SUB RebootSystem STATIC
  311.  
  312.     i% = RestartListEmpty()
  313.     i% = ExitExecRestart()
  314.  
  315. END SUB
  316.  
  317.  
  318. '**
  319. '** Purpose:
  320. '**     Appends a file name to the end of a directory path,
  321. '**     inserting a backslash character as needed.
  322. '** Arguments:
  323. '**     szDir$  - full directory path (with optional ending "\")
  324. '**     szFile$ - filename to append to directory
  325. '** Returns:
  326. '**     Resulting fully qualified path name.
  327. '*************************************************************************
  328. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  329.     IF szDir$ = "" THEN
  330.     MakePath = szFile$
  331.     ELSEIF szFile$ = "" THEN
  332.     MakePath = szDir$
  333.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  334.     MakePath = szDir$ + szFile$
  335.     ELSE
  336.     MakePath = szDir$ + "\" + szFile$
  337.     END IF
  338. END FUNCTION
  339.